
dnl# -*- sh -*-
dnl# the "configure" script is made from this by running GNU "autoconf"
dnl#
dnl# Configuration script for TinyWidget
dnl#
dnl# Copyright (C) 2001, Century Software Embedded Technologies
dnl# Written by Jordan Crouse
dnl#
dnl# This library is free software; you can redistribute it and/or
dnl# modify it under the terms of the GNU Lesser General Public
dnl# License as published by the Free Software Foundation; either
dnl# version 2.1 of the License, or (at your option) any later version.
dnl#
dnl# This library is distributed in the hope that it will be useful,
dnl# but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dnl# Lesser General Public License for more details.
dnl# 
dnl# You should have received a copy of the GNU Lesser General Public
dnl# License along with this library; if not, write to the Free Software
dnl# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

AC_INIT(README)

dnl# If they specified a host, then make sure the paths are all correct

AC_CANONICAL_SYSTEM

dnl# Borrowed from tsch configure script - it alerts the user to the fact that the
dnl# cache has different info

AC_MSG_CHECKING([cached host tuple])
if { test x"${ac_cv_host_system_type+set}" = x"set" &&
     test x"$ac_cv_host_system_type" != x"$host"; }; then
  AC_MSG_RESULT([different])
  AC_MSG_ERROR([remove config.cache and re-run configure])
else
  AC_MSG_RESULT(ok)
fi
ac_cv_host_system_type="$host"

dnl# For our purposes, we want whatever the user entered, its easier that way, so
dnl# set host accordingly for rest of the script

host=$host_alias
 
echo "Configuring TinyWidgets for $host"

AC_CHECK_TOOL(CC, gcc, :)
AC_CHECK_TOOL(LD, ld, :)
AC_CHECK_TOOL(AR, ar, :)
AC_CHECK_TOOL(RANLIB, ranlib, :)

dnl# Now, ensure that the tools we specified above work like they should

AC_PROG_CC

CFLAGS="-Wall"
INCLUDES=""
LIBS="-ltnW"

dnl# Determine if this is to be linked against shared or static libraries
AC_ARG_ENABLE(debug, [ --enable-debug  Builds the code with debug information],
[
       echo "Building with debug information"
       CFLAGS="$CFLAGS -O0 -g"
],
[
    CFLAGS="$CFLAGS -O2"
])

dnl# Determine if this is to be linked against shared or static libraries
AC_ARG_ENABLE(static, [ --enable-static  Informs the makefile to link with static libraries],
[
       echo "Linking with static libraries"
       LDFLAGS="$LDFLAGS --static"
])

AC_ARG_WITH(microwin, [  --with-microwin=[microwindows base path]  Specifies where Microwindows lives], 
[ 
  echo "Using Microwindows from $with_microwin..."
  MWFOLDER=$with_microwin
  INCLUDES="$INCLUDES -I$MWFOLDER/include" 
  LIBS="$LIBS -L$MWFOLDER/lib -lnano-X -lX11"
  NANOX=1 
],
[
  echo "Using Microwindows from default location..."
  INCLUDES="$INCLUDES -I/usr/include/microwin" 
  LIBS="$LIBS -L/usr/lib -lnano-X -lX11"
])

AC_PROG_MAKE_SET

AC_SUBST(INCLUDES)
dnl# AC_SUBST(CC)
dnl# AC_SUBST(LD)
dnl# AC_SUBST(AR)
dnl# AC_SUBST(RANLIB)

AC_OUTPUT(Make.rules Makefile src/Makefile demos/Makefile tndesigner/Makefile)
